<?php

use yii\db\Migration;

/**
 * Handles the creation of table `plan_data`.
 */
class m180223_092556_create_plan_data_table extends Migration
{
    /**
     * @inheritdoc
     */
    public function up()
    {
        $tableOptions = null;
        if ($this->db->driverName === 'mysql') {
            // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
        }
        $this->createTable('{{%plan_data}}', [
            'id' => $this->primaryKey(),
            'complete' => $this->integer(11)->notNull()->defaultValue(0)->comment('已完成金额'),
            'contract' => $this->integer(11)->notNull()->defaultValue(0)->comment('当前合同金额'),
            'created_at' => $this->integer(11)->notNull()->comment('添加时间'),
            'updated_at' => $this->integer(11)->notNull()->comment('修改时间')
        ], $tableOptions);
    }

    /**
     * @inheritdoc
     */
    public function down()
    {
        $this->dropTable('{{%plan_data}}');
    }
}
